/**
 * @(#)UserSessionServiceImpl.java Dec 13, 2009
 *   
 * Copyright  (c) 2009-2010 Wilmar IT Service,  Inc.   
 * All  rights  reserved.   
 * TODO
 */

package test.system.web.actions;

import java.util.Locale;
import java.util.Map;

import javax.servlet.http.HttpSession;

import com.wilmar.process.entity.User;
import com.wilmar.process.exception.NoUserSessionException;
import com.wilmar.process.web.spi.IUserSessionService;

/**
 * @author makubex Email:makubexnet@gmail.com
 * @version 1.0.0
 */
public class UserSessionServiceImpl implements IUserSessionService {

	/**
	 * @see com.wilmar.process.web.actions.IUserSession#getCurrentUserObject()
	 */
	public User getCurrentUserObject() throws NoUserSessionException {
		throw new NoUserSessionException("This method is unsupported!");
	}

	/**
	 * @see com.wilmar.process.web.actions.IUserSession#getCurrentUserObject(java.util.Map)
	 */
	public User getCurrentUserObject(Map<String, Object> session)
			throws NoUserSessionException {
		User u = (User) session.get("currentuser");
		if (u == null)
			throw new NoUserSessionException("Not login in");
		return u;
	}

	/**
	 * @see com.wilmar.process.web.spi.IUserSessionService#getUserLocale()
	 */
	public Locale getUserLocale() {
		return new Locale("zh", "CN");
	}

	/**
	 * @see com.wilmar.process.web.spi.IUserSessionService#getUserLocale(javax.servlet.http.HttpSession)
	 */
	public Locale getUserLocale(HttpSession session) {
		return null;
	}

	/**
	 * @see com.wilmar.process.web.spi.IUserSessionService#getCurrentUserObject(javax.servlet.http.HttpSession)
	 */
	public User getCurrentUserObject(HttpSession session)
			throws NoUserSessionException {
		User u = (User) session.getAttribute("currentuser");
		if (u == null)
			throw new NoUserSessionException("Not login in");
		return u;
	}

	/**
	 * @see com.wilmar.process.web.spi.IUserSessionService#getUserLocale(java.util.Map)
	 */
	public Locale getUserLocale(Map<String, Object> session)
			throws NoUserSessionException {
		return null;
	}

}
